Ext.define('PC.view.FormPorcino', {
    extend:'Ext.form.Panel',
    id:'FormPorcino',
    widget:'widget.FormPorcino',
//    height:250,
//    width:400,
    bodyPadding:10,
//    title:'My Form',

    initComponent:function () {
        var me = this;

        Ext.applyIf(me, {
            items:[
                {
                    xtype:'textfield',
                    fieldLabel:'Codigo',
                    name:'codigo'
                },
                {
                    xtype:'button',
                    text:'Aceptar',
                    handler:function () {
                        var form = this.up('form');
//                        form.saved(form.getValues());
//                        if (form.isValid()) {
//                        TODO analize which method is most apropiate, Ajax.request or use a Store
                        Ext.Ajax.request({
                            loadMask:true,
                            url:'/Hembras/save',
                            params:Ext.JSON.encode(form.getValues()),
                            success:function (resp) {
                                form.saved(resp);
                            }
                        });
//                        }

                    }
                }
            ]
        });
        me.callParent(arguments);
    },
    saved:function (resp) {
        //TODO add an listener for save function
        console.log('envia al servidor');
    }
});